/*=============================================================================
#    The element-comm is a tentative program used to test our ideas.           
#                       Copyright (C)  bgao                                    
#
#     This program is free software; you can redistribute it and/or            
#      modify it under the terms of the GNU General Public License             
#     as published by the Free Software Foundation; either version 2           
#         of the License, or (at your option) any later version.               
#
#     This program is distributed in the hope that it will be useful,          
#    but WITHOUT ANY WARRANTY; without even the implied warranty of           
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            
#             GNU General Public License for more details.                    
#
#    You should have received a copy of the GNU General Public License        
#     along with this program; if not, write to the Free Software             
#      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,             
#                       MA  02110-1301, USA.                                  
#==============================================================================
# $Id: common.h 348 2010-11-29 09:01:16Z bgao $ 
#
# $Author: bgao $ 
#
# $Revision: 348 $ 
#
# $Date: 2010-11-29 17:01:16 +0800 (星期一, 29 十一月 2010) $ 
#
# Description: 
#
=============================================================================*/
/*! @file common.h
 *  @brief This is common included interfaces which defines
 *         the basic types.
 */         
#ifndef _COMMON_H_
#define _COMMON_H_

/*! macro switch used to turn debug output on or off. */
//#define debug_switch_on

#ifdef debug_switch_on
#define MAC_DEBUG printf
#else
#define MAC_DEBUG(...) 
#endif

/*! the basic data types */
typedef unsigned char      uint8;
typedef unsigned short     uint16;
typedef unsigned long      uint32;
typedef unsigned long long uint64;

typedef char               int8;
typedef short              int16;
typedef long               int32;
typedef long long          int64;

/*! the address mode value */
typedef enum _mac_addr_m_value_t_ {
    NOT_PRESENT = 0b0,
    ADDR_16_M   = 0b10,
    ADDR_64_M   = 0b11,
} mac_addr_m_value_t;

/*! bool type */
#ifndef bool
#define bool uint8
#endif

#ifndef _bool
#define _bool
enum _bool {
    true = 1,
    false = 0
};
#endif

/*! address type */
typedef struct _addr_t {
    uint8 mode;
    union {
        uint64 addr64;
        uint16 addr16;
    } a;
} addr_t;

/*! MAC status value */
typedef enum mac_status_t_ {
    MAC_OK = 0,
    MAC_ERR = -1,
    MAC_TEST_ERR = -2,

    MAC_PAN_AT_CAPACITY = 0x01,
    MAC_ACCESS_DENIED = 0x02,
    MAC_ASSOC_SUCCESS = 0x00,

    /* from 802.15.4 */
    MAC_BEACON_LOSS = 0xe0,
    MAC_CHANNEL_ACCESS_FAILURE = 0xe1,
    MAC_COUNTER_ERROR = 0xdb,
    MAC_DENIED = 0xe2,
    MAC_DISABLE_TRX_FAILURE = 0xe3,
    MAC_FRAME_TOO_LONG = 0xe5,
    /* enumerations related with security process */
    MAC_IMPROPER_KEY_TYPE = 0xdc,
    MAC_IMPROPER_SECURITY_LEVEL = 0xdd,
    MAC_INVALID_ADDRESS = 0xf5,
    MAC_INVALID_GTS = 0xe6,
    MAC_INVALID_HANDEL = 0xe7,
    MAC_INVALID_INDEX = 0xf9,
    MAC_INVALID_PARAMETER = 0xe8,
    MAC_LIMIT_REACHED = 0xfa,
    MAC_NO_ACK = 0xe9,
    MAC_NO_BEACON = 0xea,
    MAC_NO_SHORT_ADDRESS = 0xec,
    MAC_ON_TIME_TOO_LONG = 0xf6,
    MAC_OUT_OF_CAP = 0xed,
    MAC_PAN_ID_CONFLICT = 0xee,
    MAC_PAST_TIME = 0xf7,
    MAC_READ_ONLY = 0xfb,
    MAC_REALIGNMENT = 0xef,
    MAC_SCAN_IN_PROGRESS = 0xfc,
    MAC_SECURITY_ERROR = 0xe4,
    MAC_SUPERFRAM_OVERLAP = 0xfd,
    MAC_TRACKING_OFF = 0xf8,
    MAC_TRANSACTION_EXPIRED = 0xf0,
    MAC_TRANSACTION_OVERFLOW = 0xf1,
    MAC_TX_ACTIVE = 0xf2,
    MAC_UNAVAILABLE_KEY = 0xf3,
    MAC_UNSUPPORTED_ATTRIBUTE = 0xf4,
    MAC_UNSUPPORTED_LEGACY = 0xde,
    MAC_UNSUPPORTED_SECURITY = 0xdf,
    MAC_NO_DATA = 0xeb,
} mac_status_t;

#endif /* _COMMON_H_ */
